package com.senken.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.senken.util.DCSTest;
import com.senken.util.UploadFile;

@Controller
public class MainController {
	
	@RequestMapping("/add")
	public String toform(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "form";
        }
        return "login";
	}
	@RequestMapping("/request")
	public String tocost(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "request";
        }
        return "login";
	}
	@RequestMapping("/signup")
	public String tosignup(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "signup";
        }
        return "login";
	}
	
	@RequestMapping("/express")
	public String toexpress(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "express";
        }
        return "login";
	}
	
	@RequestMapping("/addexpress")
	public String addexpress(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "addexpress";
        }
        return "login";
	}
	
	@RequestMapping("/cpwd")
	public String cpwd(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "cpwd";
        }
        return "login";
	}
	
	@RequestMapping("/declare")
	public String todeclare(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "declare";
        }
        return "login";
	}
	
	@RequestMapping("/install")
	public String toinstall(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "install";
        }
        return "login";
	}
	
	@RequestMapping("/train")
	public String totrain(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "train";
        }
        return "login";
	}
	@RequestMapping("/return")
	public String toreturn(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "return";
        }
        return "login";
	}
	
	@RequestMapping("/finish")
	public String tofinish(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "finish";
        }
        return "login";
	}
	
	@RequestMapping("/approve")
	public String toapprove(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "approve";
        }
        return "login";
	}
	
	@RequestMapping("/addreturn")
	public String toaddreturn(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "addreturn";
        }
        return "login";
	}
	
	@RequestMapping("/user")
	public String touser(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "user";
        }
        return "login";
	}
	
	@RequestMapping("/returnfinish")
	public String toreturnfinish(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "returnfinish";
        }
        return "login";
	}
	
	@RequestMapping("/expressfinish")
	public String toexpressfinish(){
		if (SecurityUtils.getSubject().isAuthenticated()) {
            return "expressfinish";
        }
        return "login";
	}
	
	@RequestMapping("/uploadfile")
	@ResponseBody
	public Object uploadfile(HttpServletRequest request,HttpServletResponse response){
		try {
			return UploadFile.UpLoad(request, response);
		} catch (Exception e) {	
			e.printStackTrace();
			return "false";
		}
	}
	
}
